import { Router } from 'express';
import { FileController, upload } from '../controllers/file-controller';
import { authMiddleware } from '../middleware/auth';

const router: Router = Router();

// 上传单个文件
router.post(
  '/upload',
  authMiddleware,
  upload.single('file'),
  FileController.uploadSingle
);

// 上传多个文件
router.post(
  '/upload-multiple',
  authMiddleware,
  upload.array('files', 5),
  FileController.uploadMultiple
);

// 获取文件URL
router.get('/url/:fileName', authMiddleware, FileController.getFileUrl);

// 删除文件
router.delete('/:fileName', authMiddleware, FileController.deleteFile);

// 获取文件列表
router.get('/list', authMiddleware, FileController.listFiles);

export default router;
